package com.ll.gulimall.ware.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ll.gulimall.ware.entity.WareSkuEntity;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;


/**
 * 商品库存
 * 
 * @author liliang
 * @email liliang@gmail.com
 * @date 2020-07-31 01:02:00
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    /**
     * 添加库存
     * @param skuId
     * @param wareId
     * @param skuNum
     */
    void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

    Long hasStock(Long skuId);

    List<Long> findSkuHashStock(@Param("skuId") Long skuId);

    Long lockSkuStocked(@Param("skuId") Long skuId, @Param("num") Integer num, @Param("wareId") Long wareId);

    void releaseWare(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);
}
